
const db = require('../serve/db.js')
function result(status,data,msg){
    this.status = status;
    this.data = data || {};
    this.msg = msg;
}

async function about(req,res){
        let data = {
          token:req.body.token ||1,
          title:req.body.title || 0,
          content: req.body.content || 0,
          CreateTime:Date.parse(new Date())/1000,
          hash:Math.random().toString(36).substr(2,10)
        };
        for(var i in data){
          if(!data[i]){
            res.send(new result(110,'',i+'未填写！'));
            return
          }
        }
        delete data.token;
        db.insert('Commit',data);
        res.send(new result(200,{},'填写正确'));
}

module.exports = about